import request from '@/util/request'

// 用户主页
export function getInfoByName(username, page, size) {
  return request({
    url: '/user/' + username,
    method: 'get',
    params: {
      pageNo: page,
      size: size
    }
  })
}
// 用户主页
export function getInfo() {
  return request({
    url: '/user/info',
    method: 'get'
  })
}
//更新
export function update(user) {
  return request({
    url: '/user/update',
    method: 'post',
    data: user
  })
}
//检查密码
export function checkUserPassword(username, oldPassword) {
  return request({
    url: '/user/checkUserPassword',
    method: 'get',
    params: {
      username: username,
      oldPassword: oldPassword
    }
  })
}

//更改密码
export function updatePassword(username, oldPassword, newPassword) {
  return request({
    url: '/user/updatePassword',
    method: 'post',
    params: {
      username: username,
      oldPassword: oldPassword,
      newPassword: newPassword
    }
  })
}

//更改邮箱
export function updateEmail(username, email) {
  return request({
    url: '/user/updateEmail',
    method: 'post',
    params: {
      username: username,
      email: email
    }
  })
}